<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/9 0009
 * Time: 11:01
 */

namespace app\wap\controller;
use think\Db;

class About extends Base
{
        public function index(){
            $data = Db::name('connect')->where('is_show =1 and sign="mobile"')->find();
            $this->assign('data',$data);
            return $this->fetCh();
    }

        public function md(){
            $md_type=intval(input('param.type'));
            $where ='is_del=0 and is_show=1 and sign="mobile"';

            if($md_type > 0){
                $where.=' and type ='.$md_type;

                $this->assign('md_type',$md_type);
            }else{
                $where.=' and type =1';

                $this->assign('md_type',1);
            }
            $data = Db::name('store_address')->where($where)->order('sort desc,id desc')->limit(3)->select();
            $this->assign('data',$data);

            $type =1;
            //判断第二页是否有数据
            $next_data= Db::name('store_address')->where($where)->page(2,3)->select();
            if(!$next_data){
                $type =2;
            }
            $this->assign('type',$type);
            return $this->fetch();
        }

    public function getMore(){
        $page = intval(input('page'));
        $md_type = intval(input('md_type'));
        $where ='is_del=0 and is_show=1 and sign="mobile"';
        if($md_type){
            $where.=' and type = '.$md_type;
        }
        $type =1;
        $res= Db::name('store_address')->where($where)->page($page,10)->select();
        $next_data= Db::name('store_address')->where('is_del=0 and is_show=1 and sign="mobile"')->page($page+1,3)->select();
        if(!$next_data){
            $type =2;
        }
        if($res){
            return json(['code'=>1,'data'=>$res,'type'=>$type]);
        }else{
            return json(['code'=>0,'msg'=>'没有更多了','type'=>$type]);
        }

    }



}